﻿<%@ Page Title="Title" Language="C#" Inherits="System.Web.Mvc.ViewPage<Uber.Core.Model.Account>"
    MasterPageFile="~/Views/Shared/Site.Master" %>

<asp:Content runat="server" ID="Title" ContentPlaceHolderID="TitleContent">
</asp:Content>
<asp:Content runat="server" ID="Main" ContentPlaceHolderID="MainContent">
    <script type="text/javascript">
        $(function () {
            $.post('<%=Url.Action("Rows") %>', { p: 1 }, function (r) {
                fill(r, { p: 1 });
            });

            $('#sms').click(function () {
                $.post('<%=Url.Action("SaveMailSettings") %>',
                    { MailOnAnswer: $('#MailOnAnswer').is(':checked'), MailOnComment: $('#MailOnComment').is(':checked') },
                    function (r) {
                        if (r == "o") {
                            $('.response').html('mail settings have been saved');
                            setTimeout("$('.response').html('');", 2000);
                        }
                        else $('.err').html('sorry, error occurred');
                    });
            });
        });

        function fill(r, sd) {
            if (r == null) return;
            $('#ns').append(r.c);
            if (r.m) {
                $('#ns').append(
            $('<li></li>').append($('<div class="more">more</div>').click(function () {
                sd.p++;
                var x = $(this);
                x.after('<span>Loading...</span>');
                x.hide();
                $.post('<%=Url.Action("Rows") %>', sd, function (da) { x.parent().remove(); fill(da, sd); });
            }))
            );
            }
        }
    </script>
    <h1>
        My notifications</h1>
    <br />
    <form class="ib" method="POST" action="<%=Url.Action("ReadAll") %>">
    <%=Html.AntiForgeryToken() %>
    <input class="mb" type="submit" value="Mark all as read" />
    </form>
    <form class="ib" method="POST" action="<%=Url.Action("DeleteAll") %>">
    <%=Html.AntiForgeryToken() %>
    <input class="mb" type="submit" value="Delete all" onclick="return confirm('are you sure ?')" />
    </form>
    <ul id="ns">
    </ul>
    <br />
    <div>
        <div class="efield">
            <%=Html.CheckBox("MailOnAnswer") %>
            <label for="MailOnAnswer">
                Send email for new answers</label>
        </div>
        <div class="efield">
            <%=Html.CheckBox("MailOnComment") %>
            <label for="MailOnComment">
                Send email for new comments</label>
        </div>
        <div class="efield">
            <button type="button" class="grbtn" id="sms">
                Save</button>
        </div>
    </div>
    <div class="response">
    </div>
    <div class="err">
    </div>
    <p>
        emails will be sent to
        <%=Model.Mail %>
        <a href="<%=Url.Action("edit","profile") %>">change</a></p>
</asp:Content>
